<p>This rule is deprecated, and will eventually be removed.</p>
<p>Executing XPATH expressions is security-sensitive. It has led in the past to the following vulnerabilities:</p>
<ul>
  <li> <a href="https://www.cve.org/CVERecord?id=CVE-2016-6272">CVE-2016-6272</a> </li>
  <li> <a href="https://www.cve.org/CVERecord?id=CVE-2016-9149">CVE-2016-9149</a> </li>
  <li> <a href="https://www.cve.org/CVERecord?id=CVE-2012-4837">CVE-2012-4837</a> </li>
</ul>
<p>User-provided data such as URL parameters should always be considered as untrusted and tainted. Constructing XPath expressions directly from
tainted data enables attackers to inject specially crafted values that changes the initial meaning of the expression itself. Successful XPath
injections attacks can read sensitive information from the XML document.</p>
<h2>Ask Yourself Whether</h2>
<ul>
  <li> the XPATH expression might contain some unsafe input coming from a user. </li>
</ul>
<p>You are at risk if you answered yes to this question.</p>
<h2>Recommended Secure Coding Practices</h2>
<p>Sanitize any user input before using it in an XPATH expression.</p>
<h2>Sensitive Code Example</h2>
<pre>
// === Server side ===

var xpath = require('xpath');
var xmldom = require('xmldom');

var doc = new xmldom.DOMParser().parseFromString(xml);
var nodes = xpath.select(userinput, doc); // Sensitive
var node = xpath.select1(userinput, doc); // Sensitive
</pre>
<pre>
// === Client side ===

// Chrome, Firefox, Edge, Opera, and Safari use the evaluate() method to select nodes:
var nodes = document.evaluate(userinput, xmlDoc, null, XPathResult.ANY_TYPE, null); // Sensitive

// Internet Explorer uses its own methods to select nodes:
var nodes = xmlDoc.selectNodes(userinput); // Sensitive
var node = xmlDoc.SelectSingleNode(userinput); // Sensitive
</pre>
<h2>See</h2>
<ul>
  <li> OWASP - <a href="https://owasp.org/www-project-top-ten/2017/A1_2017-Injection">Top 10 2017 Category A1 - Injection</a> </li>
  <li> CWE - <a href="https://cwe.mitre.org/data/definitions/643">CWE-643 - Improper Neutralization of Data within XPath Expressions</a> </li>
</ul>
